home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 3 / Amiga Format CD03 (1996-07-04)(Future Publishing)(GB)(Track 1 of 6)[!][issue 1996-08].iso / comms / netsoftware / sana2_cslip.lha / slip_device.asm < prev    next >
Assembly Source File  |  1993-06-25  |  3KB  |  181 lines

  1. **
  2. ** $Source: hog:Other/networking/sana2/src/slip/RCS/slip_device.asm,v $
  3. ** $State: Exp $
  4. ** $Revision: 37.3 $
  5. ** $Date: 92/08/25 16:42:36 $
  6. ** $Author: kcd $
  7. **
  8. ** Amiga SANA2 Example SLIP Device Driver
  9. **
  10. ** (C) Copyright 1992 Commodore-Amiga, Inc.
  11. **
  12.  
  13.  
  14.     SECTION firstsection
  15.  
  16.     NOLIST
  17.  
  18.     include "exec/types.i"
  19.     include "exec/devices.i"
  20.     include "exec/initializers.i"
  21.     include "exec/memory.i"
  22.     include "exec/resident.i"
  23.     include "exec/io.i"
  24.     include "exec/ables.i"
  25.     include "exec/errors.i"
  26.     include "exec/tasks.i"
  27.     include "utility/tagitem.i"
  28.     include "dos/dos.i"
  29.     include "dos/dosextens.i"
  30.     include "dos/dostags.i"
  31.     include "devices/serial.i"
  32.     include "devices/sana2.i"
  33.     include "slip_device.i"
  34.     include "slip_rev.i"
  35.  
  36.     LIST
  37.  
  38. ABSEXECBASE    EQU    4    ;Absolute location of the pointer to exec.library base
  39. **
  40. ** First executable location
  41. **
  42.  
  43. FirstAddress:
  44.     moveq    #-1,d0
  45.     rts
  46.  
  47. SLIPPRI   EQU    5
  48.  
  49.     XREF    _SLIPName
  50.     XREF    EndCode
  51.  
  52. initDDescrip:
  53.                     ; STRUCTURE RT,0
  54.     DC.W    RTC_MATCHWORD        ; UWORD RT_MATCHWORD (Magic cookie)
  55.     DC.L    initDDescrip        ; APTR    RT_MATCHTAG  (Back pointer)
  56.     DC.L    EndCode         ; APTR    RT_ENDSKIP   (To end of this hunk)
  57.     DC.B    RTF_AUTOINIT        ; UBYTE RT_FLAGS     (magic-see "Init:")
  58.     DC.B    VERSION         ; UBYTE RT_VERSION
  59.     DC.B    NT_DEVICE        ; UBYTE RT_TYPE      (must be correct)
  60.     DC.B    SLIPPRI         ; BYTE    RT_PRI
  61.     DC.L    _SLIPName        ; APTR    RT_NAME      (exec name)
  62.     DC.L    idString        ; APTR    RT_IDSTRING  (text string)
  63.     DC.L    Init            ; APTR    RT_INIT
  64.                     ; LABEL RT_SIZE
  65.  
  66. ** This is an identifier tag to help in supporting the device
  67. ** format is 'name version.revision (dd MON yyyy)',<cr>,<lf>,<null>
  68.  
  69. idString:    VSTRING
  70.  
  71. ** Force word alignment
  72.  
  73.     CNOP    0,4
  74.  
  75. Init:
  76.     DC.L    SLIPDev_Sizeof    ; data space size
  77.     DC.L    DevFuncTable    ; pointer to function initializers
  78.     DC.L    0        ; pointer to data initializers (unused)
  79.     DC.L    DevInit     ; routine to run
  80.  
  81. **
  82. ** Standard System Routines
  83. **
  84.  
  85.     XREF    _DevOpen
  86.     XREF    _DevClose
  87.     XREF    _DevExpunge
  88.     XREF    _DevBeginIO
  89.     XREF    _DevAbortIO
  90.  
  91. **
  92. ** Other misc. routines
  93. **
  94.     XDEF    _ExtDeviceBase
  95.     XDEF    @IPToNum
  96.  
  97. V_DEF    MACRO
  98.     DC.W    \1+(*-DevFuncTable)
  99.     ENDM
  100.  
  101. DevFuncTable:
  102.     DC.W    -1
  103.     V_DEF    _DevOpen
  104.     V_DEF    _DevClose
  105.     V_DEF    _DevExpunge
  106.     V_DEF    DevReserved
  107.     V_DEF    _DevBeginIO
  108.     V_DEF    _DevAbortIO
  109.     DC.W    -1
  110.  
  111. **
  112. ** Rhialto: Our only global variable. Since it is constant as long as
  113. ** we're in existence, this is not harmful. And it's better than hoping
  114. ** (or praying, as they like to do in the USA) the compiler doesn't
  115. ** clobber A6.
  116.  
  117. _ExtDeviceBase    dc.l    0
  118.  
  119. **
  120. ** initRoutine
  121. **
  122. ** Called after device has been allocated.
  123. ** This routine is single threaded
  124. **
  125. ** Register Usage
  126. **
  127. ** a3 - Pointer to temporary RAM
  128. ** a4 - Pointer to expansion.library base
  129. ** d0 - Pointer to device struct
  130. ** a6 - Pointer to Exec Base
  131.  
  132. DevInit:
  133.     movem.l a0/a5,-(sp)
  134.     movea.l d0,a5
  135.     move.l    d0,_ExtDeviceBase        ; Rhialto
  136.     move.w    #REVISION,LIB_REVISION(a5)
  137.     move.l    a6,sd_SysLib(a5)
  138.     move.l    a0,sd_SegList(a5)
  139.     lea.l    sd_Lock(a5),a0
  140.     jsrlib    InitSemaphore
  141.     move.l    a5,d0
  142.     movem.l (sp)+,a0/a5
  143.     rts
  144.  
  145. DevReserved:
  146.     moveq.l #0,d0
  147.     rts
  148.  
  149. @IPToNum:
  150.     movem.l d2,-(sp)
  151.     bsr.s    StrToNum
  152.     lsl.w    #8,d0
  153.     move.w    d0,d2
  154.     bsr.s    StrToNum
  155.     move.b    d0,d2
  156.     swap    d2
  157.     bsr.s    StrToNum
  158.     lsl.w    #8,d0
  159.     move.w    d0,d2
  160.     bsr.s    StrToNum
  161.     move.b    d0,d2
  162.     move.l    d2,d0
  163.     movem.l (sp)+,d2
  164.     rts
  165.  
  166. StrToNum:
  167.     moveq    #0,d0
  168.     moveq    #0,d1
  169. 1$    move.b    (a0)+,d1
  170.     cmp.b    #'0',d1
  171.     bcs.s    2$            ; was blo
  172.     cmp.b    #'9',d1
  173.     bhi.s    2$
  174.     sub.b    #'0',d1
  175.     mulu    #10,d0
  176.     add.w    d1,d0
  177.     bra.s    1$
  178. 2$    rts
  179.  
  180.     END
  181.